/**
 * N里面选M个，且位置之差大于等于K，问最大权值和
 * O(NM)
 * 令Dij是前i个中选j个的最大值
 * 令Uij是以i结尾的选j个的最大值
 * Uij = max{D[i-k][j-1] + Ai}
 * Dij = max{D[i-1][j],  U[i][j]}
 * 其实直接用Dij就可以了
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;

llt const INF = 0x1F2F3F4F5F6F7F8F;
llt const NINF = -INF;

int N, M, K;
vector<llt> A;
vector<vector<llt>> D;
vector<vector<llt>> U;

llt chkadd(llt a, llt b){
    if(a == NINF or b == NINF) return NINF;
    return a + b;
}

void chkmax(llt & a, llt b){
    if(b == NINF) return;
    if(a == NINF or a < b) a = b;
    return;
}

void work(){
    cin >> N >> M >> K;
    A.assign(N + 1, 0);
    for(int i=1;i<=N;++i) cin >> A[i];

    U.assign(N + 1, vector<llt>(M + 1, NINF));
    D.assign(N + 1, vector<llt>(M + 1, NINF));
    D[0][0] = U[0][0] = 0;
    D[1][0] = 0;
    D[1][1] = U[1][1] = A[1];

    for(int i=2;i<=K;++i){
        D[i][0] = 0;
        U[i][1] = A[i];
        D[i][1] = D[i - 1][1];
        chkmax(D[i][1], U[i][1]); 
    }

    for(int i=K+1;i<=N;++i){
        D[i][0] = 0;
        for(int j=1;j<=min(i, M);++j){
            U[i][j] = chkadd(D[i - K][j - 1], A[i]);
            D[i][j] = D[i - 1][j];
            chkmax(D[i][j], U[i][j]);
        }
    }
    cout << D[N][M] << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase; 
    while(nofkase--) work();
    return 0;
}
